﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace ProductMonitor.OpCommand
{
    public class Command : ICommand
    {
        /// <summary>
        /// 定义委托
        /// </summary>
        private Action _exceute;

        /// <summary>
        /// 接受执行方法
        /// </summary>
        /// <param name="exceute"></param>
        public Command(Action exceute)
        {
            _exceute = exceute;
        }

            public event EventHandler? CanExecuteChanged;

        /// <summary>
        /// 能否执行
        /// </summary>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public bool CanExecute(object? parameter)
        {
            return true;
        }

        /// <summary>
        /// 执行方法
        /// </summary>
        /// <param name="parameter"></param>
        /// <exception cref="NotImplementedException"></exception>
        public void Execute(object? parameter)
        {
            _exceute?.Invoke();
        }
    }
}
